/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.File;

/**
 * <p>Project: javaseapp - Dir2
 * <p>Powered by webrx On 2021-08-11 09:07:50
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Dir6 {
    public static void main(String[] args) {
        //删除c:/myuser 目录，它是非目录
        //del(new File("c:/myuser"));
        File f = new File(".");
        System.out.println(f.getAbsolutePath());
    }

    /**
     * 递归方法，实现删除非空目录
     */
    public static void del(File file) {
        if (file.exists() && file.isDirectory()) {
            for (File t : file.listFiles()) {
                if (t.isDirectory()) {
                    del(t);
                } else {
                    t.delete();
                }
            }
        } else {
            file.delete();
        }
        file.delete();
    }
}
